﻿using Ross.EntityFramework.Model;
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Ross.EntityFramework
{
    [DbConfigurationType(typeof(MySql.Data.Entity.MySqlEFConfiguration))]
    public partial class TranDbContext : DbContext
    {
        public TranDbContext(string ConnStr)
            : base(ConnStr)
        {
            Database.SetInitializer<TranDbContext>(null);
        }
        public TranDbContext()
            : base("name=TranDbContext")
        {
            //策略一：数据库不存在时重新创建数据库
            //Database.SetInitializer<TranDbContext>(new CreateDatabaseIfNotExists<TranDbContext>());
            //策略二：每次启动应用程序时创建数据库
            //Database.SetInitializer<RossLiveDbContext>(new DropCreateDatabaseAlways<RossLiveDbContext>());
            //策略三：模型更改时重新创建数据库
            //Database.SetInitializer<RossLiveDbContext>(new DropCreateDatabaseIfModelChanges<RossLiveDbContext>());
            //策略四：从不创建数据库
            //Database.SetInitializer<RossLiveDbContext>(null);
        }
        public virtual IDbSet<Targets> Targets { get; set; }

        public virtual IDbSet<History> Historys { get; set; }
        public virtual IDbSet<Users> Users { get; set; }
        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
        }
    }
}
